<template>
	<view class="content">
		<view class="uni-list">
				 
			<!-- <navigator url="../info/info"> -->
				<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in lists" :key="index"
				 @click="openinfo" :data-newsid="item.post_id">
				
					<view class="uni-media-list" >
						<!-- <button type="primary" @tab="del(index)"删除</button> -->
						
						<view class="">
							<image class="uni-media-list-logo" :src="item.author_avatar"></image>
						</view>
							<view class="uni-midea-list-body" >
								<view class="uni-media-list-text-top">
									{{item.title}}
								</view>
								<view class="uni-media-list-text-bottom uni-ellipsis" >
									{{item.created_at}}
								</view>
							</view>
					</view>
				</view>
			<!-- </navigator> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lists:[]
			}
		},
		onLoad() {
			uni.showLoading({
				title:'加载中.....'
			});
			uni.request({
				url: 'https://unidemo.dcloud.net.cn/api/news',
				method: 'GET',
				data: {},
				success: res => {
					console.log(res)
					this.lists=res.data;
					uni.hideLoading();
				},
				fail: () => {},
				complete: () => {}
			});
		},
		methods:{
			openinfo(e) {
				var newsid = e.currentTarget.dataset.newsid;
				console.log(newsid);
				uni.navigateTo({
					url: '../info/info?newsid='+newsid
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.uni-list{
		width: 750rpx;
		height: 50px;
		padding-bottom: 30px;
	}
	.uni-list-cell{
		padding: 10px;
	}
	.uni-media-list{
		display: flex;
		align-items: flex-start;
		border-bottom: 1px solid #999999;
	}
	.uni-media-list-logo{
		width: 50px;
		height: 50px;
		padding: 10px;
	}
	.uni-midea-list-body{
		padding: 10px;
	}
	.uni-midea-list-body{
		font-size: 18px;
		color: #000;
	}
	.uni-media-list-text-bottom{
		padding: 5px;
		font-size: 14px;
		color: #999999;
	}
</style>
